<?php

    function find_room(&$details) {

        if (isset($details->rooms))
            foreach ($details->rooms as $index => $room) :
                if ($room->room_ID == $_GET['room_id']):
                    $details->cur_room = $room;

                    if (isset($details->cur_room->photos) && count($details->cur_room->photos) > 0):

                        $details->cur_room->full_path = $details->cur_room->photos[0]->full_path;
                        $details->cur_room->image_name = $details->cur_room->photos[0]->image_name;
                        $details->cur_room->image_title = $details->cur_room->photos[0]->image_title;

                        unset($details->cur_room->photos[0]);
                        $details->cur_room->photos = array_values($details->cur_room->photos);
                    endif;

                    break;
                endif;
            endforeach;
    }
    